package cn.com.shaom.learning.sb.data.mybatis.mapper.entity;

import lombok.Getter;
import lombok.Setter;
import tk.mybatis.mapper.annotation.NameStyle;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * ClassName: User
 * Description: 必须使用jPA注解
 * Date: 2017/12/26 10:37 【需求编号】
 *
 * @author Shaom
 * @version V1.0.0
 */
@Getter
@Setter
@NameStyle
@Table
public class User {

    public User() {
    }

    public User(String name) {
        this.name = name;
    }

    public User(String name, String pwd) {
        this.name = name;
        this.pwd = pwd;
    }

    // 主见策略，只用与insert方法
    @Id
    // 使用GenerationType.IDENTITY需要在全局配置中配置IDENTITY的参数值，默认是Mysql
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private String id;
    private String name;
    private String pwd;

    @Transient
    private String aa;


    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("User{");
        sb.append("id='").append(id).append('\'');
        sb.append(", name='").append(name).append('\'');
        sb.append(", pwd='").append(pwd).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
